import React, { Component } from 'react';
import * as service from "../../api/index";
import {withRouter} from 'react-router-dom'


import "../../styles/Index/Home/List.scss"

class List extends Component {
    constructor(props) {
        super(props);
        this.state = {
            indexnavlist: [
                {
                    pic:'https://img2.baidu.com/it/u=2692482832,3090067814&fm=253&fmt=auto&app=138&f=JPEG?w=499&h=378',
                    name:'会员中心',
                    key:'/vip'
                },
                {
                    pic:'https://bpic.51yuansu.com/pic3/cover/02/16/49/59aead5dc79b1_610.jpg',
                    name:'种草特辑',
                    key:'/suggest'
                },
                {
                    pic:'https://img1.baidu.com/it/u=3336904934,396358183&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
                    name:'精选品牌',
                    key:'/brand'
                },
                {
                    pic:'https://bpic.588ku.com/element_origin_min_pic/19/06/15/45d297a59ff3b36fcb86706d000bc356.jpg',
                    name:'领卷中心',
                    key:'/coupon'
                },
                {
                    pic:'https://img0.baidu.com/it/u=2300255095,3902724717&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
                    name:'签到',
                    key:'/signin'
                }
            ]
        }
    }


    render() {
        return (
            <div className='list'>
                {
                    this.state.indexnavlist.map((item, index) => {
                        return (
                            <div className="item" key={index} onClick={()=>{this.props.history.push(this.state.indexnavlist[index].key)}}>
                                <img src={item.pic} alt="" />
                                <div className="text">{item.name}</div>
                            </div>
                        )
                    })
                }
            </div>
        );
    }
}

export default withRouter(List);